<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.health.model.*"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>pressure-list</title>
</head>


<link rel="stylesheet" href="../css/css1.css" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/validate.js"></script>
<script type="text/javascript">
<!--
window.onload = function() {
	isAnyLogined();
}


//弹出新增页面
function openPressureInsert() {
	window.showModalDialog("pressure-insert.faces","","dialogHeight:200px;dialogWidth:400px;status:no;scroll:no;help:no");
}

//弹出修改页面
function openPressureUpdate() {
	window.showModalDialog("pressure-update.faces","","dialogHeight:200px;dialogWidth:400px;status:no;scroll:no;help:no");
}

//调UserBean里的 isAnyLogined()
function isAnyLogined() {
	document.getElementById('resultForm:isAnyLoginedBtn').click();
	//重新点击pressure-list的查询按钮,达到刷新列表的效果,否则我在pressure-insert页面不能刷新该列表
	document.getElementById('resultForm:searchTable:0:searchBtn').click();
}
-->
</script>

<body>
<f:view> 
<div id="welcomeDiv" >
<!-- 判空 
  <h2><a>Hi!
  <strong><u>
  <%User u = (User)session.getAttribute("currentLoginInfo");
  	if(u != null) {
		((User)session.getAttribute("currentLoginInfo")).getName(); 
  	} else {
  	}
  %>
  </u></strong> 
  welcome back ! my friend</a></h2>
 -->
</div>
<br>
<a4j:form id="resultForm">

<a4j:commandButton id="isAnyLoginedBtn" action="#{UserManagedBean.isAnyLogined }" style="display:none"></a4j:commandButton>
<h:inputHidden id="isAnyLoginedFlag" value="#{UserManagedBean.isAnyLoginedFlag }"></h:inputHidden>
	
	<!-- search condition -->
	<rich:dataTable id="searchTable" value="#{BloodPressureManagedBean.searchVo }" var="searchVo">
		<rich:column>
			<f:facet name="header">
				<h:outputLabel value="LOW"></h:outputLabel>
			</f:facet>
			<h:inputText value="#{searchVo.low1 }"></h:inputText> - 
			<h:inputText value="#{searchVo.low2 }"></h:inputText> 
		</rich:column>			
		
		<rich:column>
			<f:facet name="header">
				<h:outputLabel value="HIGH"></h:outputLabel>
			</f:facet>
			<h:inputText value="#{searchVo.high1 }"></h:inputText> - 
			<h:inputText value="#{searchVo.high2 }"></h:inputText>
		</rich:column>
		
		<rich:column>
			<a4j:commandButton id="searchBtn"  value="search" styleClass="btn"
							 action="#{BloodPressureManagedBean.selectForList }"
							 reRender="searchResultTable"
						     onmouseover="mOverBtn(this,'Find')"
							 onmouseout="mOutBtn(this,'Find')">
				<f:setPropertyActionListener value="searchVo" target="#{BloodPressureManagedBean.searchVo }"/>
			</a4j:commandButton>	
		</rich:column> 		
	</rich:dataTable>
	
	
	<table>	 
	<tr></tr>
	<hr/>
	<tr></tr>	 
	</table>	
	
	 
	<!-- search result list -->
	<a4j:commandButton id="pressure-insert" value="insert new"	styleClass="btn"
					   onclick="openPressureInsert();">
    </a4j:commandButton>
	 <rich:dataTable id="searchResultTable" 
		 				value="#{BloodPressureManagedBean.resultList }" 
		 				var="rowDataVo"
		 				width="1000px">
		 <f:facet name="header">
		 	<h:outputText>Blood Pressure List</h:outputText>
		 </f:facet>

		 	<rich:column sortBy="#{rowDataVo.userName}">
		 		<f:facet name="header">
		 			<h:outputLabel value="userName"></h:outputLabel>
		 		</f:facet>
					<h:outputLabel value="#{rowDataVo.userName }"></h:outputLabel>
		 	</rich:column>		 	
		 	<rich:column filterBy="#{rowDataVo.low }" filterEvent="onkeyup">
		 		<f:facet name="header">
		 			<h:outputLabel value="low"></h:outputLabel>
		 		</f:facet>
					<h:outputLabel value="#{rowDataVo.low }"></h:outputLabel>
		 	</rich:column >
		 	<rich:column filterBy="#{rowDataVo.high }" filterEvent="onkeyup">
		 		<f:facet name="header">
		 			<h:outputLabel value="high"></h:outputLabel>
		 		</f:facet>
					<h:outputLabel value="#{rowDataVo.high }"></h:outputLabel>
		 	</rich:column>		 		 			 	
		 	<rich:column sortBy="#{rowDataVo.examTime }" filterBy="#{rowDataVo.examTime }" filterEvent="onkeyup">
		 		<f:facet name="header">
		 			<h:outputLabel value="examtime"></h:outputLabel>
		 		</f:facet>
					<h:outputLabel value="#{rowDataVo.examTime }"></h:outputLabel>
		 	</rich:column>
		 	<rich:column>
		 		<f:facet name="header">
		 			<h:outputLabel value="remarks"></h:outputLabel>
		 		</f:facet>
					<h:outputLabel value="#{rowDataVo.remarks }"></h:outputLabel>
		 	</rich:column>	
		 	<rich:column>
		 		<f:facet name="header">
		 			<h:outputLabel value="options"></h:outputLabel>
		 		</f:facet>
					<a4j:commandLink id="detail" 
									 value="detail"
									 action="#{BloodPressureManagedBean.selectByPK }"
									 oncomplete="Richfaces.showModalPanel('pressureDetailModalPanel');"
									 reRender="pressureDetailModalPanel">
						<f:setPropertyActionListener value="#{rowDataVo.id }" target="#{BloodPressureManagedBean.pressure.id }"/>
					</a4j:commandLink>
					<rich:spacer styleClass="LinkRichSpacer" />
					<a4j:commandLink id="delete" 
									 value="delete"
									 onclick="javascript:if(!confirm('delete the data?'))return false"
									 action="#{BloodPressureManagedBean.deleteByPK }"
									 reRender="searchResultTable">
						<f:setPropertyActionListener value="#{rowDataVo.id }" target="#{BloodPressureManagedBean.pressure.id }"/>
					</a4j:commandLink>
					<rich:spacer styleClass="LinkRichSpacer" />
					<a4j:commandLink id="update" 
									 value="update"
									 action="#{BloodPressureManagedBean.selectByPK }"
									 oncomplete="openPressureUpdate();"
									 >
						<f:setPropertyActionListener value="#{rowDataVo.id }" target="#{BloodPressureManagedBean.pressure.id }"/>
					</a4j:commandLink>					
		 	</rich:column>	
		 	<!--		 	
		 	 richfaces PAGING 
		 	-->
		 	<f:facet name="footer">
		 		<rich:datascroller id="sc1"
		 						 for="searchResultTable" 
		 						 page="#{BloodPressureManagedBean.scrollerPage }">
		 		</rich:datascroller>
		 	</f:facet>
		 	
	 </rich:dataTable>

</a4j:form>


<a4j:form id="modalForm">
<!-- 弹出ModalPanel 查看血压详细信息 -->
<rich:modalPanel id="pressureDetailModalPanel"  height="120" width="580" autosized="true">
<f:facet name="header">
	<h:outputText value="bloodpressure detail"/>
</f:facet>
<f:facet name = "controls">
	<span style="cursor:pointer" onclick="javascript:Richfaces.hideModalPanel('pressureDetailModalPanel');">close</span>
</f:facet>
<rich:dataTable value="#{BloodPressureManagedBean.pressure }" var="pressure">
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="id"/>
		</f:facet>
			<h:inputText value="#{pressure.id }"/>
	</rich:column>
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="userName"/>
		</f:facet>
			<h:inputText value="#{pressure.userName }"/>
	</rich:column>	
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="low"/>
		</f:facet>
			<h:inputText value="#{pressure.low }"/>
	</rich:column>	
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="high"/>
		</f:facet>
			<h:inputText value="#{pressure.high }"/>
	</rich:column>	
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="examTime"/>
		</f:facet>
		<h:inputText value="#{pressure.examTime }">
			<f:convertDateTime pattern="yyyy-MM-dd hh:mm:ss" />
		</h:inputText>
	</rich:column>
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="remarks"/>
		</f:facet>
		<h:inputText value="#{pressure.remarks }">
		</h:inputText>
	</rich:column>
</rich:dataTable>
	<rich:column>
		<f:facet name="header">
			<h:outputText styleClass="headerText" value="operate"/>
		</f:facet>
			<a4j:commandButton id="update" value="update"
								action="#{BloodPressureManagedBean.updateByPK }">
				<f:setPropertyActionListener value="#{pressure }" target="#{BloodPressureManagedBean.pressure }"/>
			</a4j:commandButton>
	</rich:column>	
</rich:modalPanel>
</a4j:form>


</f:view>
</body>

<script type="text/javascript">
<!--



-->
</script>
</html>